  /**
   * Builds the cart Criteria
   */
  public function buildCartCriteria()
  {
    if (is_null($this->filters))
    {
      $this->filters = $this->configuration->getCartFilterForm($this->getCartFilters());
    }

    $criteria = $this->filters->buildCriteria($this->getCartFilters());

    $this->addSortCriteria($criteria);

    $event = $this->dispatcher->filter(new sfEvent($this, 'admin.cart_build_criteria'), $criteria);
    $criteria = $event->getReturnValue();

    $criteria->add(<?php echo constant($this->getModelClass()."::PEER")."::ID" ?>, $this->configuration->getCartItems(), Criteria::IN);
    return $criteria;
  }

  /**
   * Gets the cart pager
   */
  protected function getCartPager()
  {
    $pager = $this->configuration->getCartPager('<?php echo $this->getModelClass() ?>');
    $pager->setCriteria($this->buildCartCriteria());
    $pager->setPage($this->getCartPage());
    $pager->setPeerMethod($this->configuration->getPeerMethod());
    $pager->setPeerCountMethod($this->configuration->getPeerCountMethod());
    $pager->init();

    return $pager;
  }

  protected function setCartPage($page)
  {
    $this->getUser()->setAttribute('<?php echo $this->getModuleName() ?>.cart_page', $page, 'admin_module');
  }

  protected function getCartPage()
  {
    return $this->getUser()->getAttribute('<?php echo $this->getModuleName() ?>.cart_page', 1, 'admin_module');
  }

  public function executeCartAddAll(sfWebRequest $request)
  {
    $c = $this->buildCriteria();
    $c->clearSelectColumns();
    $c->addSelectColumn(<?php echo constant($this->getModelClass()."::PEER")."::ID" ?>);
    $stmt = <?php echo constant($this->getModelClass()."::PEER") ?>::doSelectStmt($c);
    $ids = $stmt->fetchAll(PDO::FETCH_COLUMN);

    $this->configuration->setCartItems($ids);

    $this->redirect('@<?php echo $this->getModuleName()?>');
  }
